extends BoarStatusBase

var walk_time:float = 0
var afraid_num:int = 0
var max_afraid_num:int = 1
func start():
	actor.play_animation("weak")
	walk_time = 0
	max_afraid_num = randi_range(3,8)
	
func run_physics_process(delta)->void:
	walk_time += delta
	actor.move_and_slide()
	if find_player() && walk_time>1.0:
		walk_time = 0
		if afraid_num > max_afraid_num:
			#拼死一搏
			return change_status("Run") 
		# 转身逃
		turn_direction()
		afraid_num+=1
		return
		
	var rand_time = randi_range(1,2)
	
	if not find_floor():
		return change_status("Idle")
	
	elif find_wall():
		if walk_time > rand_time:
			walk_time = 0
			turn_direction()
			return

	if walk_time > rand_time:
		walk_time = 0
		return change_status("Idle")
	
func run_process(delta)->void:
	common_velocity(delta,0.2)
